#include "Sequence.h"
#include <stdlib.h>
#include <time.h>

Sequence::Sequence()
{
	srand(time(NULL));
	Clear();
}

void Sequence::Generate()
{
	unsigned char move = 0;
	int random = 0;
	for (int counter = 0; counter < NOOF_MOVES; ++counter)
	{
		move = 0;

		// pick a random move type
		random = rand()%NOOF_TYPES;
		switch (random)
		{
		case 0:
			move |= ATTACK;
			break;
		case 1:
		default:
			move |= BLOCK;
			break;
		};

		// pick a random position
		random = rand()%NOOF_POSITIONS;
		switch (random)
		{
		case 0:
			move |= LOW;
			break;
		case 1:
			move |= MID;
			break;
		case 2:
		default:
			move |= HIGH;
			break;
		};

		m_moves[counter] = move;
	}
}

void Sequence::Clear()
{
	for (int counter = 0; counter < NOOF_MOVES; ++counter)
	{
		m_moves[counter] = 0;
	}
}

void Sequence::SetMove(int i_index, MoveType i_type, MovePosition i_position)
{
	m_moves[i_index] = (i_type|i_position);
}

unsigned char Sequence::GetMove(int i_index) const
{
	return m_moves[i_index];
}